home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / alib / csup / clib / doprnt.asm < prev    next >
Assembly Source File  |  1994-02-14  |  1KB  |  61 lines

  1.  
  2.     section    romhunks
  3.     xref    _Write
  4.     xref    _AbsExecBase
  5.     xref    _LVORawDoFmt
  6.     xref    _stdout
  7.  
  8.  
  9.  
  10. LF    equ    10
  11. CR    equ    13
  12.  
  13. ************************************************************************
  14. *
  15. *    doprnt -- format a string to an output stream
  16. *
  17. ************************************************************************
  18.     xdef    __doprnt
  19. __doprnt:    ; ( stream, format, values)
  20.         movem.l    a2/a3/a4/a6,-(sp)
  21.         move.l  5*4(sp),a4
  22.  
  23.     ;------ format the string:
  24.         move.l    6*4(sp),a0
  25.         move.l    7*4(sp),a1
  26.         lea    stuffChar(pc),a2
  27.         lea    -140(sp),sp    ; local string buffer
  28.         move.l    sp,a3
  29.         move.l    _AbsExecBase,a6
  30.         jsr    _LVORawDoFmt(a6)
  31.  
  32.     ;------ find end of formatted string:
  33.         moveq.l    #-1,d0
  34. ps_size:    tst.b    (a3)+
  35.         dbeq    d0,ps_size
  36.         not.l    d0
  37.         beq.s    ps_empty
  38.  
  39.     ;------ write the formatted string:
  40. ps_common:
  41.         move.l    d0,-(sp)
  42.         pea    4(sp)
  43.         pea    (a4)
  44.         jsr    _Write    (stream, &string, size)
  45.         lea    12(sp),sp
  46. ps_empty:
  47.         lea    140(sp),sp
  48.         movem.l    (sp)+,a2/a3/a4/a6
  49.         rts
  50.  
  51. ;------ putchar function used by DoFmt: --------------------------------
  52. stuffChar:
  53. *        cmp.b    #LF,d0
  54. *        bne.s    sc_put
  55. *        move.b    #CR,(a3)+
  56. sc_put:
  57.         move.b    d0,(a3)+
  58.         rts
  59.  
  60.     END
  61.